//
//  CCContactTool.m
//  MagicBox
//
//  Created by dllo on 16/8/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CCContactTool.h"

static CCContactTool *mp = nil;



@interface CCContactTool ()



@end




@implementation CCContactTool

+(instancetype)shareContactTool
{
    if (mp == nil) {
        
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            
            mp = [[CCContactTool alloc]init];
           
            mp.inviteUserInfoDic = [NSMutableDictionary dictionary];
            mp.arrayOfUsers = [NSMutableArray array];
            mp.ReceiveAddedFromUserNameArray = [NSMutableArray array];
        });
        
    }
    
    return mp;
}

-(void)addMessages:(NSString *)messages userName:(NSString *)userName{
    
    NSMutableArray *userNameOfDic = [NSMutableArray array];
    for (NSString *keyUserName in self.inviteUserInfoDic) {
        
        [userNameOfDic addObject:keyUserName];
        
    }
    
    BOOL isContains = [userNameOfDic containsObject:userName];
   
    if (!isContains) {
        
        // 如果不包含 则设立key值
        
        NSMutableArray *messagesValue = [NSMutableArray array];
        [messagesValue addObject:messages];
        
        [self.inviteUserInfoDic setObject:messagesValue forKey:userName];
        
        [self.arrayOfUsers addObject:userName];
        
    }else{
        
        // 如果包含
        NSMutableArray *meses = [self.inviteUserInfoDic objectForKey:userName];
        [meses addObject:messages];
        
        [self.inviteUserInfoDic setObject:meses forKey:userName];
        
        
    }
    
    
    
    
    
}




-(void)removeUser:(NSString *)userName
{
    
    
    if (self.inviteUserInfoDic.count != 0)
    {
        
        
        [self.arrayOfUsers removeObject:userName];
        
        
        [self.inviteUserInfoDic removeObjectForKey:userName];
        
        
    }
   
    
    
}



@end
